#ifndef LOD_TRIANGLE_H
#define LOD_TRIANGLE_H

//! Triangle
/*! 
 * \param vit_type A type used to store the indices of the vertices of this triangle.
 * \param mit_type A material (actually, an index of the material) is kept using this type. */
template<class vit_type, class mit_type>
class triangle
{
    public:
    //! Vertices (given as the indices of the real vertices)
    vit_type verts[3];
    //! Material (actually, an index of the material)
    mit_type mat;

    /*!
     * \param t A triangle to compare this one with.*/
    bool operator== (const triangle & t) const
    {
       return (verts[0]==t.verts[0] &&
               verts[1]==t.verts[1] &&
               verts[2]==t.verts[2] &&
               mat == t.mat);
    }

    /*!
     * \param v Vertices building this triangle.
     * \param m A material covering this triangle.*/
    triangle(const vit_type* v, mit_type m)
    {
        verts[0] = v[0];
        verts[1] = v[1];
        verts[2] = v[2];
        mat = m;
    }

    //! Constructor of an empty (invalid) triangle
    triangle()
    {
        verts[0] = verts[1] = verts[2] = -1;
        mat = NO_MAT;
    }

    bool has_material()
    {
        return mat!=NO_MAT;
    }

    public:
    //! This is the index of "unspecified" material (= no material)
    static const mit_type NO_MAT = -1;
};
#endif
